
<!DOCTYPE html>
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script src="http://127.0.0.1:8000/CLodopfuncs.js"></script>
<script src="LodopFuncs.js"></script>
<script src="jquery.min.js"></script>
<title>包装打印服务</title>
</head>

<body>
<h3>正在请求打印......</h3>
<script language="javascript" >
$(document).ready(function(){
  setTimeout(function () {
      //window.open("about:blank","_self").close() 
      //PrintMytable("312.9TE040300","复合母排C","WO-99958","2020-05-11","33","200511A010001","苏州市高新区珠江路521号",1,"");
      getScanPrint();     
  },500) 
});

//取得条码内容
function getScanPrint(){
  $.ajax({
    type: 'POST',
    url: "http://localhost:8888/do.g",
    dataType : 'json',
    data:{dofunc:"getScanPrint"},
    success:function(data) {
      PrintMytable(data.Part_number,data.Part_description,data.Lot_number,data.Date_s,data.Quantity,data.Batch_number,data.Address_s,1,data.Code_base64_str);
      //alert(JSON.stringify(data));
	  },
		error:function(data) {
      alert("打印请求错误！");
      window.open("about:blank","_self").close();
		}      
  });
}


function PrintMytable(PartNumber, PartDescription, LOT_Number, DateTime, qty, BillNo, Address, page, codeimageStr) {
	
	var LODOP1 = getLodop();
	LODOP.SET_LICENSES("", "688858710010010811411756128900", "", "");
	LODOP.PRINT_INIT("产品包装清单");
	LODOP.SET_PRINT_PAGESIZE(2, "700", "900", "");
	for ( var a = 0; a < page; a++) {
	LODOP.ADD_PRINT_IMAGE(5, 12, 240, 26,"<img src='wdint.bmp'/>");
	LODOP.SET_PRINT_STYLEA(1+a*35, "Stretch", 2);
	//LODOP.ADD_PRINT_TEXT(2, 240, 600, 10, "Lot No.");
	//LODOP.ADD_PRINT_TEXT(18, 240, 600, 10, "批次号");
	LODOP.ADD_PRINT_TEXT(43, 16, 600, 10, "Part Number");
	LODOP.ADD_PRINT_TEXT(58, 16, 600, 10, "零件号");
	LODOP.ADD_PRINT_TEXT(76, 16, 600, 10, "Part Description");
	LODOP.ADD_PRINT_TEXT(91, 16, 600, 10, "产品描述");
	LODOP.ADD_PRINT_TEXT(109, 16, 600, 10, "LOT Number");
	LODOP.ADD_PRINT_TEXT(124, 16, 600, 10, "工单号");
	LODOP.ADD_PRINT_TEXT(142, 16, 600, 10, "Batch Number");
	LODOP.ADD_PRINT_TEXT(157, 16, 600, 10, "批次号");
	LODOP.ADD_PRINT_TEXT(175, 16, 600, 10, "Quantity");
	LODOP.ADD_PRINT_TEXT(190, 16, 600, 10, "数量");
	LODOP.ADD_PRINT_TEXT(210, 16, 600, 10, "Date");
	LODOP.ADD_PRINT_TEXT(225, 16, 600, 10, "日期");
	//var jj = $('#codeimage').html();
  
	//LODOP.ADD_PRINT_IMAGE(31, 220, 120, 120, codeimageStr);
	//LODOP.ADD_PRINT_TEXT(145, 250, 600, 10, "Quality Tag");
  
  LODOP.ADD_PRINT_IMAGE(145, 235, 90, 90,codeimageStr);//codeimageStr
	LODOP.ADD_PRINT_TEXT(247, 16, 600, 10, Address);
	LODOP.ADD_PRINT_TEXT(247, 170, 600, 10, "www.wdint.com");
	//LODOP.ADD_PRINT_TEXT(247, 250, 600, 10, "Tel:0512-66165970");
  if (PartNumber.length >= 30) {
		LODOP.ADD_PRINT_TEXT(40, 112, 145, 40, PartNumber);
	} else {
		LODOP.ADD_PRINT_TEXT(50, 112, 260, 10, PartNumber);
	}
  if (PartDescription.length >= 30) {
		LODOP.ADD_PRINT_TEXT(79, 112, 135, 40, PartDescription);//
	} else {
		LODOP.ADD_PRINT_TEXT(83, 112, 260, 10, PartDescription);
	}

	if (LOT_Number.length >= 30) {
		LODOP.ADD_PRINT_TEXT(111, 112, 135, 40, LOT_Number);//wdiNo
	} else {
		LODOP.ADD_PRINT_TEXT(116, 112, 260, 10, LOT_Number);
	}
  
	if (BillNo.length >= 19) {
		LODOP.ADD_PRINT_TEXT(145, 112, 135, 40, BillNo);
	} else {
		LODOP.ADD_PRINT_TEXT(149, 112, 260, 10, BillNo);
	}
	
	
	LODOP.ADD_PRINT_TEXT(182, 115, 260, 10, qty);
	LODOP.ADD_PRINT_TEXT(217, 115, 600, 10, DateTime);//4位年-2位月-2位日CurentTime()
	//LODOP.ADD_PRINT_TEXT(12, 280, 260, 10, BillNo);
	for ( var i = 0; i <= 6; i++) {
		LODOP.SET_PRINT_STYLEA(2 + 2 * i+a*35, "FontSize", 8);
		LODOP.SET_PRINT_STYLEA(3 + 2 * i+a*35, "FontSize", 8);
		LODOP.SET_PRINT_STYLEA(2 + 2 * i+a*35, "FontName", "arial");
		LODOP.SET_PRINT_STYLEA(3 + 2 * i+a*35, "FontName", "arial");
		LODOP.SET_PRINT_STYLEA(2 + 2 * i+a*35, "Bold", 1);
		LODOP.SET_PRINT_STYLEA(3 + 2 * i+a*35, "Bold", 1);
		LODOP.SET_PRINT_STYLEA(21 + i+a*35, "FontName", "arial");
		LODOP.SET_PRINT_STYLEA(21 + i+a*35, "Bold", 1);
		LODOP.SET_PRINT_STYLEA(21 + i+a*35, "FontSize", 8);
	}

	LODOP.SET_PRINT_STYLEA(17+a*35, "FontSize", 9);
	LODOP.SET_PRINT_STYLEA(17+a*35, "FontName", "arial");
	LODOP.SET_PRINT_STYLEA(17+a*35, "Bold", 1);
	//LODOP.SET_PRINT_STYLEA(18,"FontName","arial");
	for ( var i = 18; i <= 20; i++) {
		LODOP.SET_PRINT_STYLEA(i+a*35, "FontName", "arial");
		LODOP.SET_PRINT_STYLEA(i+a*35, "FontSize", 8);
    LODOP.SET_PRINT_STYLEA(i+a*35, "Bold", 1);
	}

	//LODOP.SET_PRINT_STYLEA(0,"Angle",90);

	//LODOP.ADD_PRINT_IMAGE(42,235,80,80,"<img src=/barcode/createCode?code="+code+">")
	//
	LODOP.ADD_PRINT_RECT(35, 15, "313", "205", 0, 1);
	LODOP.ADD_PRINT_LINE(35, 107, 240, 107, 0, 1)
	LODOP.ADD_PRINT_LINE(139, 238, 240, 238, 0, 1)
  
	LODOP.ADD_PRINT_LINE(73, 15, 73, 328, 0, 1)
	LODOP.ADD_PRINT_LINE(106, 15, 106, 328, 0, 1)
	LODOP.ADD_PRINT_LINE(139, 15, 139, 328, 0, 1)
	LODOP.ADD_PRINT_LINE(172, 15, 172, 238, 0, 1)
	LODOP.ADD_PRINT_LINE(205, 15, 205, 238, 0, 1)
	LODOP.NewPageA();// 分页
	}
	
	//LODOP.PREVIEW();
  LODOP.PRINT();
  
  window.open("about:blank","_self").close()  
};
 
</script>

</body>
</html>
